<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="jt" uri="http://www.jsoft.org/tags/jsoft"%>
<%@ taglib prefix="jh" uri="http://www.jsoft.org/tags/jsoft-html"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	if(path!=null&&path.equals("/")){
	   path="";
	} 
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 1.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>系统角色对应Link维护</title>
		<link href="<%=basePath%>admin/styles/default.css" rel="stylesheet"
			type="text/css" />
		<script type="text/javascript" src="<%=basePath%>admin/scripts/jquery.js"></script>
		<script type="text/javascript">
        function frameHeight() {
        	var height = (window.innerHeight) ? window.innerHeight : (document.documentElement && document.documentElement.clientHeight) ? document.documentElement.clientHeight : document.body.offsetHeight;
			return height;
        }
        
        window.onload = function(){frameHeightSet();}
		window.onresize = function(){frameHeightSet();}
		
		function frameHeightSet() {
			var height = frameHeight();
        	if (height<=300) {
        		height = 300;
        	}
			document.getElementById("linkTable").style.height = height-110+"px";
			document.getElementById("roleDiv").style.height = height-128+"px";
		}
		//*************************
		function checkChange(obj)
		{
			if(obj.checked)
			{
				$("input[name='linkCheck']").each(function(){this.checked=true;});
			} 
			else
			{
				$("input[name='linkCheck']").each(function(){this.checked=false;});
			}
		}
		</script>
	</head>

	<body>
		<div class="title">
			<h2>
				系统角色对应Link维护
			</h2>
		</div>
		<div id="container">
			<!-- table -->
			<form action="<%=basePath%>manager/link/roleLinkSave.do" method="post">
				<table width="100%" cellpadding="2" cellspacing="1"
					bgcolor="#DDDDDD">
					<tr bgcolor="#FFFFFF">
						<td nowrap="nowrap" width="220">
							系统角色列表：
							<a href="<%=basePath%>manager/link/roleLink.do">刷新</a>
						</td>
						<td>
							系统Link(Url)列表：
							<c:if test="${requestScope.selectRole ne null}">
								<a href="<%=basePath%>manager/link/roleLink.do?id=${requestScope.selectRole.id}">刷新</a>
								<font color="red">
								<b><c:out value="${requestScope.selectRole.name}"></c:out></b>
								</font>
							</c:if>
							<input type="hidden" name="id" value="${requestScope.selectRole.id}" />
							<font color="red">
							${requestScope.saveMsg}
							</font>
						</td>
					</tr>
					<tr bgcolor="#FFFFFF">
						<td valign="top">
							<div id="roleDiv" style="overflow: auto;">
								<c:forEach items="${requestScope.roleList}" var="role" varStatus="status">
								<div style="padding-left: 4px;margin-bottom: 3px;margin-top: 3px;">
									<c:choose>
									<c:when test="${requestScope.selectRole.id eq role.id}">
										<c:out value="${status.index + 1}"/>)
										<font color="red"><b>${role.name}</b></font>
									</c:when>
									<c:otherwise>
										<c:out value="${status.index + 1}"/>)
										<a href="<%=basePath%>manager/link/roleLink.do?id=${role.id}">${role.name}</a>
									</c:otherwise>
									</c:choose>
								</div>
								</c:forEach>
							</div>
						</td>
						<td valign="top" align="left">
							<div id="linkTable" style="overflow: auto;">
								<!-- Link Table -->
								<table class="table01">
									<tr>
										<th width="30">
											<label for="check"> 
											<input type="checkbox" id="check" name="check" onclick="checkChange(this);" class="checkBox">
											选择
											</label>
										</th>
										<th width="20%">名称</th>
										<th>Link(Url)</th>
									</tr>
									<c:forEach items="${requestScope.linkList}" var="link">
									<tr>
										<td>
											<c:set var="checked" scope="page" value=""/>
											<c:forEach items="${requestScope.selectRole.links}" var="selectLink">
												<c:if test="${link.id eq selectLink.id}">
													<c:set var="checked" scope="page" value="checked"/>
												</c:if>
											</c:forEach>
											<input type="checkbox" class="checkBox" name="linkCheck" value="${link.id}" ${pageScope.checked} />
											<c:out value="${link.id}"/>
										</td>
										<td><c:out value="${link.name}"/></td>
										<td><c:out value="${link.linkUrl}"/></td>
									</tr>
									</c:forEach>
								</table>
								<!-- End -->
							</div>
						</td>
					</tr>
					<tr bgcolor="#FFFFFF">
						<td>
							&nbsp;
						</td>
						<td>
							<input type="submit" value="保存/修改" class="button" />
							<input type="reset" value="重置" class="button" />
						</td>
					</tr>
				</table>
			</form>
		</div>
	</body>
</html>
